import request from '@/router/axios';

export const getList = (current, size, params, isTemplate, userType) => {
  return request({
    url: '/api/rb-core/core/oempolicy/oem_policy/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      isTemplate,
      userType,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: '/api/rb-core/core/oempolicy/oem_policy/detail',
    method: 'get',
    params: {
      id
    }
  })
}

export const remove = (ids) => {
  return request({
    // url: '/api/rb-core/core/oempolicy/oem_policy/remove',
    url: '/api/rb-core/core/oempolicy/oem_policy/removeTemplate',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/rb-core/core/oempolicy/oem_policy/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/rb-core/core/oempolicy/oem_policy/submit',
    method: 'post',
    data: row
  })
}

export const getAisleList = (current, size, params) => {
  return request({
    url: '/api/rb-core/core/aisle/pay_aisle/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

/* 政策费率整体上下调 */
export const adjustRate = (row) => {
  return request({
    url: '/api/rb-core/core/oempolicy/oem_policy/adjustRate',
    method: 'post',
    data: row
  })
}

/* 模板政策新增详情 */
export const getAisleDetail = (aisleCode) => {
  return request({
    // url: '/api/rb-core/core/oempolicy/oem_policy/aisleDetail',
    url: '/api/rb-core/core/oempolicy/oem_policy/aisleDetailV2',
    method: 'get',
    params: {
      aisleCode
    }
  })
}

/* 新增或修改政策模板 */
export const addTemplatePolicy = (row) => {
  return request({
    url: '/api/rb-core/core/oempolicy/oem_policy/addTemplatePolicy',
    method: 'post',
    data: row
  })
}

export const updateTemplatePolicy = (row) => {
  return request({
    url: '/api/rb-core/core/oempolicy/oem_policy/addTemplatePolicy',
    method: 'post',
    data: row
  })
}

export const submitTemplatePolicyV2 = (row) => {
  return request({
    url: '/api/rb-core/core/oempolicy/oem_policy/addTemplatePolicyV2',
    method: 'post',
    data: row
  })
}